from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
from django.conf import settings
from blog.models import Post
from django.contrib.comments import Comment
from django.contrib.sitemaps import GenericSitemap

blog_dict = {
    'queryset': Post.objects.all(),
    'date_field': 'datetime',
}

comments_dict = {
    'queryset': Comment.objects.all(),
    'date_field': 'submit_date',
}

sitemaps = {
    'blog': GenericSitemap(blog_dict, priority=0.6),
    'comments': GenericSitemap(comments_dict, priority=0.5),
}

urlpatterns = patterns('',
    url(r'^', include('blog.urls')),

    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', include(admin.site.urls)),

    url(r'^accounts/', include('accounts.urls')),

    url(r'^comments/', include('django.contrib.comments.urls')),
    
    url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
    url(r'^robots\.txt$', 'django.views.static.serve', {'path': 'robots.txt', 'document_root': settings.STATIC_ROOT}),
)


if settings.DEBUG:
    urlpatterns += patterns('',
        url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
    )

